package org.poem;

import org.poem.entity.DemoBean;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Configuration
@SpringBootApplication
public class Main {

    @Bean
    @Profile(value = "dev")
    public DemoBean getDevDemoBean(){
        return  new DemoBean("from development profile.");
    }

    @Bean
    @Profile(value = "prod")
    public DemoBean getPreDemoBean(){
        return  new DemoBean("from production profile");
    }

    @Bean
    public DemoBean getDefault(){
        return  new DemoBean("from default profile");
    }


    public static void main(String[] args) {
        AnnotationConfigApplicationContext configApplicationContext = new AnnotationConfigApplicationContext(Main.class);
        configApplicationContext.getEnvironment().setActiveProfiles("dev");

        DemoBean demoBean = configApplicationContext.getBean(DemoBean.class);
        System.err.println(demoBean.getContent());

        configApplicationContext.close();
    }
}
